﻿using Core.SimpleTemp.Common;
using Core.SimpleTemp.Common.AutoMapperExtend;
using Core.SimpleTemp.Entitys;
using Core.SimpleTemp.Repositories;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.SimpleTemp.Application.FX
{
    /// <summary>
    /// 风险公共帮助类
    /// </summary>
    [AutoDi()]
    public class FXService
    {
        readonly IDataDicHelp _dataDicHelp;
        readonly SysAreaRepository _sysAreaRepository;
        public FXService(IDataDicHelp dataDicHelp, SysAreaRepository sysAreaRepository)
        {
            _dataDicHelp = dataDicHelp;
            _sysAreaRepository = sysAreaRepository;
        }
       

        /// <summary>
        /// 
        /// 根据工厂ID获取区域信息
        /// </summary>
        /// <param name="factory"></param>
        /// <returns></returns>
        public async Task<List<SysArea>> GetAreaByFactoryAsync()
        {
            return await _sysAreaRepository.QueryBase().ToListAsync();
        }

        /// <summary>
        /// 找出区域集合内，某名称的区域信息
        /// </summary>
        /// <param name="sysAreas"></param>
        /// <param name="areas"></param>
        /// <returns></returns>
        public SysArea FindAreaOfAreaListAsync(List<SysArea> sysAreas, string areasName)
        {
            return sysAreas.Where(a => a.Name.Equals(areasName)).FirstOrDefault();
        }
    }
}
